package cn.mihoyo.user.service.impl;

import cn.mihoyo.basic.util.UUIDUtil;
import cn.mihoyo.user.domain.User;
import cn.mihoyo.user.dto.AccountLoginDto;
import cn.mihoyo.user.mapper.UserMapper;
import cn.mihoyo.user.service.IUserService;
import cn.mihoyo.basic.service.impl.BasicServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.security.PrivateKey;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author mihoyo
 * @since 2023-08-01
 */
@Service
public class UserServiceImpl extends BasicServiceImpl<User> implements IUserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public HashMap<String, Object> accountLogin(User user) {
        HashMap<String, Object> login = new HashMap<>();
        //参数校验
        //根据账号查询数据
        User user1 = userMapper.findByUserName(user.getUsername());
        if(user1 == null){
            throw new RuntimeException("账号或者密码错误，请重试");
        }
        //比对传进来的数据是否和数据库的一样
        String token = UUIDUtil.get12UUID();
        login.put("token",token);
        return login;
    }
}
